package com.hl.controller.Test;


import com.hl.domain.Test.UserTest;
import com.hl.service.Test.UserTestService;
import com.hl.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/userTest")
public class UserTestController {
    @Autowired
    private UserTestService userTestService;

    @GetMapping("/login")
    private R selectByUsernameAndPassword(String username,String password){
        UserTest userTest = userTestService.selectByUsernameAndPassword(username, password);
        if (userTest != null){
            return R.success(userTest);
        }else {
            return R.fail("登录失败");
        }
    }
    @PutMapping("/update")
    public R update(@RequestBody UserTest userTest){
        int i = userTestService.update(userTest);
        return i >0 ? R.success("修改成功"):R.fail("修改失败");

    }
    @PostMapping ("/add")
    public R add(@RequestBody UserTest userTest){
        int i = userTestService.insert(userTest);
        return i >0 ? R.success("新增成功"):R.fail("新增失败");
    }
}
